package com.example.test1;

import com.example.test1.assistant.Assistant;
import dev.langchain4j.community.model.dashscope.QwenChatModel;
import dev.langchain4j.service.AiServices;
import dev.langchain4j.service.spring.AiService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class AIServiceTast {

    @Autowired
    private QwenChatModel qwenChatModel;
    @Test
    void contextLoads() {
    //测试,AiServices 连接Assistant和QwenChatModel模型对象,Assistant是接口用来代替OpenAiChatModel，发送和接收消息,以便对消息更灵活的处理
        Assistant ass = AiServices.create(Assistant.class, qwenChatModel);
        String answer = ass.chat("你好吗？");
        System.out.println(answer);

    }

    @Autowired
    private Assistant assistant;
    @Test
    //测试2,AiAssistant 直接依赖注入,不用手动绑定model对象
    void contextLoads2() {
        String answer = assistant.chat("你好吗？");
        System.out.println(answer);
    }
}
